package exp3

class Calculator extends Logger {

  def add(a: Int, b: Int): Unit = {
    return log("Adding " + a + " and " + b + "result is" + a + b)
  }

  def subtract(a: Int, b: Int): Unit = {
    return log("subing " + a + " and " + b + "result is" + (a - b))
  }

  override def log(message: String): Unit = {
    printf("作业完成！")
  }

  def calculate(a: Int, b: Int, c: Char): Any = c match {
    case '+' => a+b
    case '-' => a-b
    case '*' => a*b
    case '/' => a/b
    case  _ =>"Invalid operrator"
  }

  def main(args: Array[String]): Unit = {
    val calculator = new Calculator()
    calculator.add(5, 10)
    calculator.subtract(10, 5)
    println(calculator.calculate(1,4,'+'))
  }
}

